# Contributor (Fluke): Ricky Wu <rickleaf.wu@gmail.com>

_realname=lsqlite3
pkgbase=mingw-w64-lua-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-lua51-${_realname}")
pkgver=0.9.5
pkgrel=2
pkgdesc="LuaSQLite is a Lua 5 binding to allow users/developers to manipulate SQLite 2 and SQLite 3 databases (through different implementations) from lua (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="http://lua.sqlite.org"
license=("LGPL")
depends=("${MINGW_PACKAGE_PREFIX}-lua51"
         "${MINGW_PACKAGE_PREFIX}-sqlite3")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
options=('staticlibs' 'strip')
source=("http://lua.sqlite.org/index.cgi/zip/${_realname}_fsl09y.zip"
        "installpath.lua"
        "lunit.lua"
        "Makefile.mingw")
sha256sums=('4c1415c6169ceedfef55888db5bd081dadc154a868c07ad2a06e75825be21d94'
            'd9b058b10d1d6e0fc1ac9338193c8b8b25e808e00955ce13ef1c91c6af0c9d3a'
            'ae756636ed73147259cb55e13768d88bef5e7fa3373209c886ab46e8ea89b92f'
            '0f8e44da73038683dfb21430bec2beda97b070adb7c4b4f84402717e1474193e')

prepare() {
  cd "${srcdir}/${_realname}_fsl09y"
  cp ../installpath.lua .
  cp ../lunit.lua .
  cp ../Makefile.mingw .
  mkdir -p tmp
}

build() {
  #mkdir -p "build-${MINGW_CHOST}"
  cd "${srcdir}/${_realname}_fsl09y"

  make -f Makefile.mingw
}

package() {
  cd "${srcdir}/${_realname}_fsl09y"
  install -Dm755 lsqlite3.dll "${pkgdir}${MINGW_PREFIX}/lib/lua/5.1/lsqlite3.dll"
}
